﻿using System;
using System.Windows;
using Defarm.ViewModel;

namespace Defarm.View
{
    /// <summary>
    /// Interaction logic for AssortWindow.xaml
    /// </summary>
    public partial class AssortWindow : Window
    {
        public AssortWindow()
        {
            InitializeComponent();
        }

        private void AssortWindow_OnClosed(object sender, EventArgs e)
        {
            foreach (var position in ViewModelLocator.Main.Positions)
            {
                foreach (var positionInContext in ViewModelLocator.Main.Db.Positions)
                {
                    if (position.Id == positionInContext.Id)
                    {
                        positionInContext.Quantity = position.Quantity;
                        positionInContext.MaxQuantity = position.MaxQuantity;
                    }
                }
            }
            ViewModelLocator.Main.Db.SaveChanges();
        }
    }
}
